/**
 *
 * User: wangshan
 * Email wangshan@fclassroom.com
 * Date: 17-11-22
 * Time: AM 11:21
 * Explain: 项目中各个环境资源配置
 *  ----> 环境切换
 *          mack.js模拟环境启动 修改 let MOCK_ENV = true
 *          开发和正式环境启动 修改 let MOCK_ENV = false
 **/
let MOCK_ENV = true

// let MOCK_ENV = false

export function getUrls () {
  // 当前环境的host配置
  const HOST = window.location.hostname
  const ENVINFO = {
    TEACHER_HREF: 'https://api-test.fclassroom.cn',
    IMGSRC: 'https://image.fclassroom.cn/', //
    CD_ONLINE: '/cd-online', // online接口地址
    CD_LOG: '/cd-log', // 日志接口地址
    CD_PAPER: '/cd-paper', // 试卷接口地址
    SSP_PUSH: '/ssp-push', // 消息推送地址
    SSP_SCHOOL: '/ssp-school', // 学校地址
    EOP_MIS: '/eop-mis', // mis湖北教育云判断地址
    EOP_ACCOUNT: '/eop-account', // account接口地址
    SSP_METADATA: '/ssp-metadata', // 中台接口地址
    LOGSERVICE_HREF: '',
    LOGCOLLECT_SERVICE: '/jike-logcollect-service', // v2.0新埋点
    CURR_ENV: '' // 当前环境地址,
  }
  /**
   * 本地192.168.  采集环境
   */
  if (HOST.indexOf('192.168.') > -1) {
    if (process.env.NODE_ENV === 'development' && MOCK_ENV) {
      ENVINFO.TEACHER_HREF = 'http://192.168.202.196:3000'
      ENVINFO.IMGSRC = 'http://47.104.109.160:8080/'
      ENVINFO.CD_ONLINE = '/cd-online'
      ENVINFO.CD_LOG = '/cd-log'
      ENVINFO.CD_PAPER = '/cd-paper' // 试卷接口地址
      ENVINFO.SSP_PUSH = '/ssp-push' // 消息推送地址
      ENVINFO.SSP_SCHOOL = '/ssp-school' // 学校地址
      ENVINFO.EOP_MIS = '/eop-mis' // mis湖北教育云判断地址
      ENVINFO.LOGSERVICE_HREF = 'https://devjklogservice.fclassroom.com' // v2.0新埋点测试地址
      ENVINFO.LOGCOLLECT_SERVICE = '/jike-logcollect-service' // v2.0新埋点
      ENVINFO.SSP_METADATA = '/ssp-metadata'// 中台接口地址
      ENVINFO.EOP_ACCOUNT = '/eop-account'
      ENVINFO.CURR_ENV = '' // 当前环境地址
    } else {
      ENVINFO.TEACHER_HREF = `https://api-test.fclassroom.cn`
      ENVINFO.IMGSRC = 'http://47.104.109.160:8080/'
      ENVINFO.CD_ONLINE = '/cd-online'
      ENVINFO.CD_LOG = '/cd-log'
      ENVINFO.CD_PAPER = '/cd-paper' // 试卷接口地址
      ENVINFO.SSP_PUSH = '/ssp-push' // 消息推送地址
      ENVINFO.SSP_SCHOOL = '/ssp-school' // 学校地址
      ENVINFO.EOP_MIS = '/eop-mis' // mis湖北教育云判断地址
      ENVINFO.LOGSERVICE_HREF = 'https://devjklogservice.fclassroom.com' // v2.0新埋点测试地址
      ENVINFO.LOGCOLLECT_SERVICE = '/jike-logcollect-service' // v2.0新埋点
      ENVINFO.SSP_METADATA = '/ssp-metadata'// 中台接口地址
      ENVINFO.EOP_ACCOUNT = '/eop-account'
      ENVINFO.CURR_ENV = '' // 当前环境地址
    }
  }
  /**
   * 本地10.8  采集环境
   */
  if (HOST.indexOf('10.8') > -1) {
    if (process.env.NODE_ENV === 'development' && MOCK_ENV) {
      ENVINFO.TEACHER_HREF = 'http://10.0.2.124:3000'
      ENVINFO.IMGSRC = 'http://47.104.109.160:8080/'
      ENVINFO.CD_ONLINE = '/cd-online'
      ENVINFO.CD_LOG = '/cd-log'
      ENVINFO.CD_PAPER = '/cd-paper' // 试卷接口地址
      ENVINFO.SSP_PUSH = '/ssp-push' // 消息推送地址
      ENVINFO.SSP_SCHOOL = '/ssp-school' // 学校地址
      ENVINFO.EOP_MIS = '/eop-mis' // mis湖北教育云判断地址
      ENVINFO.LOGSERVICE_HREF = 'https://devjklogservice.fclassroom.com' // v2.0新埋点测试地址
      ENVINFO.LOGCOLLECT_SERVICE = '/jike-logcollect-service' // v2.0新埋点
      ENVINFO.SSP_METADATA = '/ssp-metadata'// 中台接口地址
      ENVINFO.EOP_ACCOUNT = '/eop-account'
      ENVINFO.CURR_ENV = '' // 当前环境地址
    } else {
      ENVINFO.TEACHER_HREF = `https://api-test.fclassroom.cn`
      ENVINFO.IMGSRC = 'http://47.104.109.160:8080/'
      ENVINFO.CD_ONLINE = '/cd-online'
      ENVINFO.CD_LOG = '/cd-log'
      ENVINFO.CD_PAPER = '/cd-paper' // 试卷接口地址
      ENVINFO.SSP_PUSH = '/ssp-push' // 消息推送地址
      ENVINFO.SSP_SCHOOL = '/ssp-school' // 学校地址
      ENVINFO.EOP_MIS = '/eop-mis' // mis湖北教育云判断地址
      ENVINFO.LOGSERVICE_HREF = 'https://devjklogservice.fclassroom.com' // v2.0新埋点测试地址
      ENVINFO.LOGCOLLECT_SERVICE = '/jike-logcollect-service' // v2.0新埋点
      ENVINFO.SSP_METADATA = '/ssp-metadata'// 中台接口地址
      ENVINFO.EOP_ACCOUNT = '/eop-account'
      ENVINFO.CURR_ENV = '' // 当前环境地址
    }
  }
  /**
   * 本地10.0 本地环境
   * 外网访问地址：http://blackhumors.6655.la:25168/
   */
  if (HOST.indexOf('10.0') > -1) {
    if (process.env.NODE_ENV === 'development' && MOCK_ENV) {
      ENVINFO.TEACHER_HREF = 'http://10.0.2.124:3000'
      ENVINFO.IMGSRC = 'http://47.104.109.160:8080/'
      ENVINFO.CD_ONLINE = '/cd-online'
      ENVINFO.CD_LOG = '/cd-log'
      ENVINFO.CD_PAPER = '/cd-paper' // 试卷接口地址
      ENVINFO.SSP_PUSH = '/ssp-push' // 消息推送地址
      ENVINFO.SSP_SCHOOL = '/ssp-school' // 学校地址
      ENVINFO.EOP_MIS = '/eop-mis' // mis湖北教育云判断地址
      ENVINFO.LOGSERVICE_HREF = 'https://devjklogservice.fclassroom.com' // v2.0新埋点测试地址
      ENVINFO.LOGCOLLECT_SERVICE = '/jike-logcollect-service' // v2.0新埋点
      ENVINFO.SSP_METADATA = '/ssp-metadata'// 中台接口地址
      ENVINFO.EOP_ACCOUNT = '/eop-account'
      ENVINFO.CURR_ENV = '' // 当前环境地址
    } else {
      ENVINFO.TEACHER_HREF = `https://api-test.fclassroom.cn`
      ENVINFO.IMGSRC = 'http://47.104.109.160:8080/'
      ENVINFO.CD_ONLINE = '/cd-online'
      ENVINFO.CD_LOG = '/cd-log'
      ENVINFO.CD_PAPER = '/cd-paper' // 试卷接口地址
      ENVINFO.SSP_PUSH = '/ssp-push' // 消息推送地址
      ENVINFO.SSP_SCHOOL = '/ssp-school' // 学校地址
      ENVINFO.EOP_MIS = '/eop-mis' // mis湖北教育云判断地址
      ENVINFO.LOGSERVICE_HREF = 'https://devjklogservice.fclassroom.com' // v2.0新埋点测试地址
      ENVINFO.LOGCOLLECT_SERVICE = '/jike-logcollect-service' // v2.0新埋点
      ENVINFO.SSP_METADATA = '/ssp-metadata'// 中台接口地址
      ENVINFO.EOP_ACCOUNT = '/eop-account'
      ENVINFO.CURR_ENV = '' // 当前环境地址
    }
  }
  /**
   * 开发dev环境
   */
  if (HOST.indexOf('teacher-dev.fclassroom.cn') > -1) {
    ENVINFO.TEACHER_HREF = `https://api-dev.fclassroom.cn`
    ENVINFO.IMGSRC = 'https://image.fclassroom.cn/'
    ENVINFO.CD_ONLINE = '/cd-online'
    ENVINFO.CD_LOG = '/cd-log'
    ENVINFO.CD_PAPER = '/cd-paper' // 试卷接口地址
    ENVINFO.SSP_PUSH = '/ssp-push' // 消息推送地址
    ENVINFO.SSP_SCHOOL = '/ssp-school' // 学校地址
    ENVINFO.EOP_MIS = '/eop-mis' // mis湖北教育云判断地址
    ENVINFO.LOGSERVICE_HREF = 'https://devjklogservice.fclassroom.com' // v2.0新埋点测试地址
    ENVINFO.LOGCOLLECT_SERVICE = '/jike-logcollect-service' // v2.0新埋点
    ENVINFO.SSP_METADATA = '/ssp-metadata'// 中台接口地址
    ENVINFO.EOP_ACCOUNT = '/eop-account'
    ENVINFO.CURR_ENV = 'https://teacher-dev.fclassroom.cn' // 当前环境地址
  }
  /**
   * 提测test环境
   */
  if (HOST.indexOf('teacher-test.fclassroom.cn') > -1) {
    ENVINFO.TEACHER_HREF = `https://api-test.fclassroom.cn`
    ENVINFO.IMGSRC = 'https://image.fclassroom.cn/'
    ENVINFO.CD_ONLINE = '/cd-online'
    ENVINFO.CD_LOG = '/cd-log'
    ENVINFO.CD_PAPER = '/cd-paper' // 试卷接口地址
    ENVINFO.SSP_PUSH = '/ssp-push' // 消息推送地址
    ENVINFO.SSP_SCHOOL = '/ssp-school' // 学校地址
    ENVINFO.EOP_MIS = '/eop-mis' // mis湖北教育云判断地址
    ENVINFO.LOGSERVICE_HREF = 'https://devjklogservice.fclassroom.com' // v2.0新埋点测试地址
    ENVINFO.LOGCOLLECT_SERVICE = '/jike-logcollect-service' // v2.0新埋点
    ENVINFO.SSP_METADATA = '/ssp-metadata'// 中台接口地址
    ENVINFO.EOP_ACCOUNT = '/eop-account'
    ENVINFO.CURR_ENV = 'https://teacher-test.fclassroom.cn' // 当前环境地址
  }
  /**
   * 预发布cn环境
   */
  if (HOST.indexOf('teacher-pre.fclassroom.cn') > -1) {
    ENVINFO.TEACHER_HREF = `https://api-pre.fclassroom.cn`
    ENVINFO.IMGSRC = 'https://image.fclassroom.cn/'
    ENVINFO.CD_ONLINE = '/cd-online'
    ENVINFO.CD_LOG = '/cd-log'
    ENVINFO.CD_PAPER = '/cd-paper' // 试卷接口地址
    ENVINFO.SSP_PUSH = '/ssp-push' // 消息推送地址
    ENVINFO.SSP_SCHOOL = '/ssp-school' // 学校地址
    ENVINFO.EOP_MIS = '/eop-mis' // mis湖北教育云判断地址
    ENVINFO.LOGSERVICE_HREF = 'https://devjklogservice.fclassroom.com' // v2.0新埋点测试地址
    ENVINFO.LOGCOLLECT_SERVICE = '/jike-logcollect-service' // v2.0新埋点
    ENVINFO.SSP_METADATA = '/ssp-metadata'// 中台接口地址
    ENVINFO.EOP_ACCOUNT = '/eop-account'
    ENVINFO.CURR_ENV = 'https://teacher-pre.fclassroom.cn' // 当前环境地址
  }
  /**
   * 正式上线com环境
   */
  if (HOST.indexOf('teacher.fclassroom.com') > -1) {
    ENVINFO.TEACHER_HREF = `https://teacher.fclassroom.com`
    ENVINFO.IMGSRC = 'https://image.fclassroom.com/'
    ENVINFO.CD_ONLINE = '/cd-online' // 网阅端cd-online
    ENVINFO.CD_LOG = '/cd-log'
    ENVINFO.CD_PAPER = '/cd-paper' // 试卷接口地址
    ENVINFO.SSP_PUSH = '/ssp-push' // 消息推送地址
    ENVINFO.SSP_SCHOOL = '/ssp-school' // 学校地址
    ENVINFO.EOP_MIS = '/eop-mis' // mis湖北教育云判断地址
    ENVINFO.LOGSERVICE_HREF = 'https://logservice.fclassroom.com' // v2.0新埋点地址
    ENVINFO.LOGCOLLECT_SERVICE = '/jike-logcollect-service' // v2.0新埋点
    ENVINFO.SSP_METADATA = '/ssp-metadata'// 中台接口地址
    ENVINFO.EOP_ACCOUNT = '/eop-account'
    ENVINFO.CURR_ENV = 'https://teacher.fclassroom.com' // 当前环境地址
  }
  return ENVINFO
}
